package com.huika.dealontop.control.shops.holder;

import android.content.Context;
import android.view.View;
import android.widget.RatingBar;
import android.widget.TextView;

import com.huika.dealontop.R;
import com.huika.dealontop.control.base.extend.BaseViewHolder;
import com.huika.dealontop.support.domain.ProductEvaluationItemBean;
import com.huika.dealontop.utils.DateTimeTool;
import com.huika.dealontop.utils.ImageLoaderHelper;
import com.huika.dealontop.utils.UIUtils;
import com.huika.dealontop.views.RoundImageView;
import com.huika.huikalib.utils.MoneyShowTool;

/**
 * Author: Victor Wu <br/>
 * Email: victor-wu*foxmail.com <br/>
 * Time: 2015/11/23 21:09 <br/>
 * Description: 商品评价
 */
public class ProductEvaluationItemHolder extends BaseViewHolder<ProductEvaluationItemBean> {
    private RoundImageView mIvIcon;
    private TextView mTvUserName;
    private RatingBar mRvEvaScore;
    private TextView mTvEvaScore;
    private TextView mTvEvaTime;
    private TextView mTvEvaContent;

    public ProductEvaluationItemHolder(Context context) {
        super(context);
    }

    @Override
    protected View initView() {
        View view = View.inflate(UIUtils.getContext(), R.layout.product_evaluation_item, null);
        mIvIcon = (RoundImageView) view.findViewById(R.id.iv_evaluation_user_icon);
        mTvUserName = (TextView) view.findViewById(R.id.tv_evaluation_user_name);
        mRvEvaScore = (RatingBar) view.findViewById(R.id.rb_evaluation_score);
        mTvEvaScore = (TextView) view.findViewById(R.id.tv_evaluation_score);
        mTvEvaTime = (TextView) view.findViewById(R.id.tv_evaluation_time);
        mTvEvaContent = (TextView) view.findViewById(R.id.tv_evaluation_content);
        return view;
    }

    @Override
    protected void refreshView(ProductEvaluationItemBean evaluation) {
        ImageLoaderHelper.displayImage(evaluation.getHeadImage(), mIvIcon, R.mipmap.my_infomation_user_icon);
        mTvUserName.setText(evaluation.getNickName());
        mRvEvaScore.setRating(Float.parseFloat(MoneyShowTool.formatOne(evaluation.getEvalScore())));
        mTvEvaScore.setText(MoneyShowTool.formatOne(evaluation.getEvalScore()));
        mTvEvaTime.setText(DateTimeTool.dmyDate(evaluation.getEvalTime() * 1000));
        mTvEvaContent.setText(evaluation.getEvalContent());
    }
}
